package com.mine.modules.vm.controller;


import com.mine.common.domain.vo.Result;
import com.mine.modules.vm.domain.dto.AssetsFileDto;
import com.mine.modules.vm.domain.query.AssetsFilePageQuery;
import com.mine.modules.vm.service.IVmAssetsFileService;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;


/**
 * @author xujf
 * @since 2024-09-21
 */
@RestController
@RequestMapping("/vm/asset/file")
@RequiredArgsConstructor
@Api(tags = "设备-资料管理")
public class VmAssetsFileController {

    private final IVmAssetsFileService vmAssetsFileService;


    @GetMapping(value = "/pageList")
    @ApiOperation("分页查询资料")
    public Result<?> pageList(AssetsFilePageQuery pageQuery) {
        return vmAssetsFileService.pageList(pageQuery);
    }

    @PostMapping(value = "/addAssetsFile")
    @ApiOperation("添加设备资料")
    public Result<?> addAssetsFile(AssetsFileDto assetsFile) {
        return vmAssetsFileService.addAssetsFile(assetsFile);
    }

    @ApiOperation("删除设备资料")
    @PostMapping(value = "/deleteById")
    public Result<?> deleteById(@RequestParam String deviceId, @RequestParam String fileId) {
        return vmAssetsFileService.deleteById(deviceId, fileId);
    }

    @ApiOperation("批量删除设备资料")
    @PostMapping(value = "/deleteBatch")
    public Result<?> deleteBatch(@RequestParam String deviceId, @RequestParam String fileIds) {
        return vmAssetsFileService.deleteBatch(deviceId, fileIds);
    }

    @ApiOperation(value = "下载设备资料")
    @GetMapping("/download")
    public ResponseEntity<byte[]> downloadFile(@RequestParam String deviceId, @RequestParam String fileId) {
        return vmAssetsFileService.download(deviceId, fileId);
    }

}
